/*
 *  LLJniSystemInfo.cpp
 *  LID Library
 *
 *  Created by Alexander Trutchenko on 09/11/11.
 *  Copyright 2011 League of Independent Developers. All rights reserved.
 *
 */
 
#include "lid_lib/src/service/android/LLJniSystemInfo.h"

#include "lid_lib/src/service/android/LLJniHelper.h"
#include "lid_lib/src/service/LLLog.h" 

#include <android/log.h>
#include <jni.h>




namespace lidlib {

std::string ll_getPackageName()
{
	std::string retVal;
	LLJniMethodInfo t;

	if (LLJniHelper::getStaticMethodInfo(t, 
				"com/lidlib/lib/LidlibCommon",
				"getPackageName",
				"()Ljava/lang/String;"))
	{
		jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID);
		t.env->DeleteLocalRef(t.classID);
		retVal = LLJniHelper::jstring2string(str);
		
		LLLOG("lidlib::ll_getPackageNameJNI(): package name %s", retVal.c_str());
	}

	return retVal;
}


std::string ll_getCurrentLanguage()
{
	std::string retVal;
	LLJniMethodInfo t;

	if (LLJniHelper::getStaticMethodInfo(t, 
				"com/lidlib/lib/LidlibCommon",
				"getCurrentLanguage",
				"()Ljava/lang/String;"))
	{
		jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID);
		t.env->DeleteLocalRef(t.classID);
		retVal = LLJniHelper::jstring2string(str);

		LLLOG("ll_getCurrentLanguageJNI(): language name %s", retVal.c_str());
	}

	return retVal;
}
	
} // namespace lidlib
